package com.inforich.web.controller.removalreport;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.inforich.common.annotation.Log;
import com.inforich.common.core.controller.BaseController;
import com.inforich.common.enums.BusinessType;
import com.inforich.common.utils.poi.ExcelUtil;
import com.inforich.removalreport.domain.RubbishRemovalReport;
import com.inforich.removalreport.domain.RubbishRemovalReportCell;
import com.inforich.removalreport.service.IRubbishRemovalReportService;

/**
 * 拆迁项目统计Controller
 *
 * @author liujie
 * @date 2022-11-28
 */
@RestController
@RequestMapping("/report/removalreport")
public class RubbishRemovalReportController extends BaseController {

  @Autowired
  private IRubbishRemovalReportService rubbishRemovalReportService;

  /**
   * 查询拆迁项目统计列表
   */
  @PreAuthorize("@ss.hasPermi('report:removalreport:list')")
  @GetMapping("/list")
  public Page<RubbishRemovalReportCell> list(Page<RubbishRemovalReportCell> page,
      RubbishRemovalReport rubbishRemovalReport) {
    Map<String, Object> map = beanToMap(rubbishRemovalReport);
    rubbishRemovalReportService.pageRubbishRemovalReportCell(page, map);
    return page;
  }

  /**
   * 导出拆迁项目统计列表
   */
  @PreAuthorize("@ss.hasPermi('report:removalreport:export')")
  @Log(title = "拆迁项目统计", businessType = BusinessType.EXPORT)
  @PostMapping("/export")
  public void export(HttpServletResponse response, RubbishRemovalReport rubbishRemovalReport) {
    Map<String, Object> map = beanToMap(rubbishRemovalReport);
    List<RubbishRemovalReportCell> list = rubbishRemovalReportService.listRubbishRemovalReportCell(
        map);
    ExcelUtil<RubbishRemovalReportCell> util = new ExcelUtil<RubbishRemovalReportCell>(
        RubbishRemovalReportCell.class);
    util.exportExcel(response, list, "拆迁项目统计");
  }
}
